package app.cn.com.school.activity

import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.support.v4.app.Fragment
import app.cn.com.school.R
import app.cn.com.school.adapter.MyViewPagerAdapter
import app.cn.com.school.databinding.ActivityPrefectureBinding
import app.cn.com.school.fragment.PrefectureFragment
import app.cn.com.school.tools.Constants

/**
 * 会员专区
 * */
class PrefectureActivity : BaseActivity<ActivityPrefectureBinding>() {
    override fun initBindingVar() {
    }

    override fun initTitle() {
        binding.titlebar.title.text = "会员专区"
        binding.titlebar.back.setOnClickListener { finish() }
    }

    private var fragemnts = ArrayList<Fragment>()
    private val titles = arrayOf("VIP1", "VIP2", "VIP3")
    lateinit var context: Context
    private var adapter: MyViewPagerAdapter? = null
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        initBinding(R.layout.activity_prefecture)
        context = this
        initView()
    }

    private fun initView() {
        fragemnts.add(PrefectureFragment().newInstance(1))
        fragemnts.add(PrefectureFragment().newInstance(2))
        fragemnts.add(PrefectureFragment().newInstance(3))
        adapter = MyViewPagerAdapter(supportFragmentManager, fragemnts, titles)
        binding.preViewpager.adapter = adapter
        binding.preTab.setupWithViewPager(binding.preViewpager)
        binding.preTab.setTabsFromPagerAdapter(adapter)
//        binding.preTab.post { Constants.setIndicator(binding.preTab, 60, 60) }

        //立即开通会员
        binding.payPrefecture.setOnClickListener {
            startActivity(Intent(context, BecomeMembrtActivity::class.java))
        }

    }
}
